package logic

import (
	"context"
	"med-sys/model/mysql"

	"med-sys/medrpc/internal/svc"
	"med-sys/medrpc/medrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MedShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMedShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MedShowLogic {
	return &MedShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *MedShowLogic) MedShow(in *medrpc.MedShowRequest) (*medrpc.MedShowResponse, error) {
	// todo: add your logic here and delete this line

	var med mysql.Doc

	err := med.MedShow(mysql.DB, in.MedId)
	if err != nil {
		return nil, err
	}

	return &medrpc.MedShowResponse{
		Name: med.Name,
		Type: med.Type,
		Text: med.Text,
	}, nil
}
